package com.rui.common.util;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @Auther: xierui
 * @Date: 2020/10/21 20:48
 * @Description:
 */
public class ShellTool {

    public static void exec(String cmd) {
//    public static void main(String[] args) {
        // Java调用 dos命令
        try {
            Process process = Runtime.getRuntime().exec(cmd); //args[0]
            InputStream is = process.getInputStream();
            InputStreamReader isr = new InputStreamReader(is, "GBK");
            BufferedReader br = new BufferedReader(isr);
            String content = br.readLine();
            while (content != null) {
                System.out.println(content);
                content = br.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}